package com.westvalley.syn.cron;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.aop.Enhancer;
import com.jfinal.kit.LogKit;
import com.westvalley.syn.service.HrDepartmentSerivce;
import com.westvalley.syn.service.HrJobActivitiesService;
import com.westvalley.syn.service.HrJobGroupService;
import com.westvalley.syn.service.HrJobTitleService;
import com.westvalley.syn.service.HrJobTitleTempletService;
import com.westvalley.syn.service.HrResourceService;
import com.westvalley.syn.service.HrSubCompanyService;
import com.westvalley.syn.service.SynService;

import weaver.interfaces.schedule.BaseCronJob;

/**
 * HRM数据同步定时计划
 * @author mos
 *
 */
public class HrSynCron extends BaseCronJob{
	@Override
	public void execute() {
		List<SynService> list = new ArrayList<SynService>();
		list.add(Enhancer.enhance(HrSubCompanyService.class));
		list.add(Enhancer.enhance(HrDepartmentSerivce.class));
		list.add(Enhancer.enhance(HrJobGroupService.class));
		list.add(Enhancer.enhance(HrJobActivitiesService.class));
		list.add(Enhancer.enhance(HrJobTitleTempletService.class));
		list.add(Enhancer.enhance(HrJobTitleService.class));
		list.add(Enhancer.enhance(HrResourceService.class));
		for(int i=0;i<list.size();i++){
			SynService service = list.get(i);
			try{
				if(i!=0 && service!=null)
					Thread.sleep( 1000 * 60 * 10 );
				service.executeSynData();
			}catch (Exception e) {
				LogKit.error("HRM同步异常！",e);
			}
		}
		
	}
}
